package struct.scene.items
{
	import com.common.displayObjects.Component;
	
	import data.ItemVO;
	
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.DisplayObject;
	import flash.display.Graphics;
	import flash.display.Shape;
	
	import utils.Util;

	/**
	 * 地图上的道具
	 * @author Administrator
	 * 
	 */	
	public class MapItem extends Component
	{
		public var id:String;
		public var isExcution:Boolean;
		public var itemVO:ItemVO;
		public var award:int; //奖励
		public var buff:String;// buff
		public var r:int = 15;
		
		public function MapItem(itemVO:ItemVO)
		{
			this.id = itemVO.id;
			this.itemVO = itemVO;
			award = itemVO.award;
			buff = itemVO.buff;
			super();
		}
		
		public var testBorder:Shape; //检测边界
		override protected function createChildren():void
		{
			super.createChildren();
			
			testBorder = new Shape();
			var g:Graphics = testBorder.graphics;
			g.beginFill(0xff0000, .2);
			g.drawCircle(0, 0, r);
			g.endFill();
			addChild(testBorder);
			
			if (itemVO.bitmapClassname =="")return;
			var c:Class = Util.getClass(itemVO.bitmapClassname);
			var ui:* = new c();
			if (ui is BitmapData)
			{
				var bm:Bitmap = new Bitmap(ui);
				bm.x = - bm.width * .5;
				bm.y = - bm.height * .5;
				addChild(bm);
			}else
			{
				ui.x = - (ui as DisplayObject).width * .5;
				ui.y = - (ui as DisplayObject).height * .5;
				addChild(ui);
			}
		}
			
		public function excution():void
		{
			if (!isExcution)return;
			
		}
		
	}
}